package xio.ccf_201604;

import java.util.Scanner;

/**
 * ccf 201604-1 折点 100
 * Created by ywb47 on 2017/9/28.
 */
public class BreakPoint {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int[] data = new int[count];
        for (int i = 0; i < count; i++) {
            data[i] = sc.nextInt();
        }

        sc.close();
        int result = 0;
        for (int i = 1; i < data.length-1; i++) {
            if ((data[i-1] > data[i] && data[i+1]>data[i]
            || (data[i-1]<data[i] && data[i+1] < data[i]))){
                result++;
            }
        }
        System.out.println(result);

    }
}
